package com.collect.zambia.zhiScene.zhiWidget.zhiPopupWindow;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.collect.zambia.R;
import com.collect.zambia.zhiUtils.DisplayUtil;
import com.collect.zambia.zhiUtils.StringUtil;
import com.collect.zambia.zhiUtils.TextViewUtil;

public class ZHIPopupTelemaketingFollowItem extends RelativeLayout {
    private Context mContext;
    private View mView;
    private ImageView iv_pop_follow_check;
    private TextView tv_pop_follow_title;
    private boolean mCheck = false;
    private String mContent = "";

    public ZHIPopupTelemaketingFollowItem(Context context) {
        this(context, null);
    }

    public ZHIPopupTelemaketingFollowItem(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public ZHIPopupTelemaketingFollowItem(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.mContext = context;
        initView();
    }

    private void initView() {
        mView = View.inflate(mContext, R.layout.pop_item_telemaketing_follow, this);
        iv_pop_follow_check = mView.findViewById(R.id.iv_pop_follow_check);
        tv_pop_follow_title = mView.findViewById(R.id.tv_pop_follow_title);
    }

    public void setContent(String content) {
        mContent = StringUtil.safeString(content);
        tv_pop_follow_title.setText(content);
    }

    public String getContent() {
        return mContent;
    }

    public void setCheck(Boolean check) {
        mCheck = check;
        if (check) {
            iv_pop_follow_check.setImageResource(R.drawable.ic_142);
        } else {
            iv_pop_follow_check.setImageResource(R.drawable.ic_143);
        }
    }

    public boolean isChecked() {
        return mCheck;
    }

    public int getMinDisplayWidth() {
        //img w+tv l+img l+tv r
        int edgWidth = DisplayUtil.dip2px(mContext, 12F + 10 * 3F + 10F);
        int maxTextLength = (int) TextViewUtil.getTextWidth(tv_pop_follow_title);

        return edgWidth + maxTextLength;
    }
}
